package com.encryption.feature.user.ui.render
{
	import com.encryption.rpc.model.User;
	
	import flashx.textLayout.formats.VerticalAlign;
	
	import mx.containers.HBox;
	
	public class UserOperationItemRenderer extends HBox
	{
		private var _data:Object;
		
		private var _operationLabelArray:Array = [new UserViewOperationLabel(), new UserAuditOperationLabel(), new UserDeleteOperationLabel()];
		
		private var isInit:Boolean = false;
		
		public function UserOperationItemRenderer()
		{
			super();
			
			setStyle("verticalAlign", VerticalAlign.MIDDLE);
		}
		
		override public function set data(value:Object):void
		{
			super.data = value;
			
			_data = value;
			
			if(_data == null)
				return;
			
			initLabelArray();
		}
		
		override protected function createChildren():void
		{
			super.createChildren();
			
			if(isInit == false){
				
				for each(var operationLabel:UserOperationLabel in _operationLabelArray){
					addChild(operationLabel);
				}
				
				isInit = true;
			}
		}
		
		private function initLabelArray():void
		{
			if(_data == null)
				return;
			
			for each(var operationLabel:UserOperationLabel in _operationLabelArray){
				operationLabel.data = _data as User;
			}
		}
		
	}
}